package com.etcsoft.pagedesigner.view;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

import com.etcsoft.pagedesigner.common.Log;
import com.etcsoft.pagedesigner.model.ProjectItem;

/**
 * @author korman21@gmail.com
 *
 */
public class ProjectLabelProvider extends LabelProvider {

    /* (non-Javadoc)
     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
     */
    @Override
    public Image getImage(Object element) {
        if (element instanceof ProjectItem) {
            ProjectItem item = (ProjectItem) element;
            Log.debug("Resource Type : " + item.getType());

            return item.getType().getImage();
        }
        return super.getImage(element);
    }

    /* (non-Javadoc)
     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
     */
    @Override
    public String getText(Object element) {
        if (element instanceof ProjectItem) {
            return ((ProjectItem) element).getName();
        }
        return super.getText(element);
    }
}
